package org.swimv2.model;

import java.io.Serializable;
import javax.persistence.*;
import java.util.List;


/**
 * The persistent class for the abilita database table.
 * 
 */
@Entity
@NamedQueries({
@NamedQuery(name="Abilita.findByUtente", query="SELECT a FROM Abilita a, Persona p WHERE p.userID=:userId AND a MEMBER OF p.abilitas"),
@NamedQuery(name="Abilita.findByNome", query="SELECT a FROM Abilita a WHERE a.nome=:abilita"),
@NamedQuery(name="Abilita.findAll", query="SELECT a FROM Abilita a")
})
public class Abilita implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	private String nome;

	//bi-directional many-to-many association to Lavoro
	@ManyToMany
	@JoinTable(
		name="`lavoro-abilita`"
		, joinColumns={
			@JoinColumn(name="NomeAbilita")
			}
		, inverseJoinColumns={
			@JoinColumn(name="IDLavoro")
			}
		)
	private List<Lavoro> lavoros;

	//bi-directional many-to-many association to Persona
	@ManyToMany(mappedBy="abilitas")
	private List<Persona> personas;

	public Abilita() {
	}

	public String getNome() {
		return this.nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public List<Lavoro> getLavoros() {
		return this.lavoros;
	}

	public void setLavoros(List<Lavoro> lavoros) {
		this.lavoros = lavoros;
	}

	public List<Persona> getPersonas() {
		return this.personas;
	}

	public void setPersonas(List<Persona> personas) {
		this.personas = personas;
	}
	@Override
	public boolean equals(Object obj){
		if(obj instanceof Abilita){
			return ((Abilita) obj).getNome().equals(this.getNome());
		}
		return false;
	}
	
	@Override
	public int hashCode(){
		int hash = 3;
		hash = 59 * hash + (this.nome != null ? this.nome.hashCode() : 0);
		return hash;
	}

}